package me.jiatao.jetpack.room;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;

import java.util.List;

import io.reactivex.Flowable;

/**
 * Created by JiaTao on 2018/10/10.
 * Email: 535318720@qq.com
 * Version: 1.0
 * Description:
 */
@Dao
public interface UserDao {
    @Query("SELECT * FROM userTable")
    Flowable<List<User>> getAllUser();

    @Query("SELECT * FROM userTable WHERE uid IN (:userIds)")
    List<User> loadAllByIds(int[] userIds);

    @Query("SELECT * FROM userTable WHERE first_name LIKE :first AND  last_name LIKE :last LIMIT 1")
    User findByName(String first, String last);

    @Insert
    void insertAll(User... users);

    @Delete
    int delete(User user);
}
